package LeetCode;

import java.util.ArrayList;

public class Subsets {
    public static void main(String[] args) {
        String[] source = {"a", "b", "c"};
        ArrayList<String> prefix = new ArrayList<>();
        ArrayList<ArrayList<String>> result = new ArrayList<>();
        get_subsets(source, prefix, 0, result);
        System.out.println(result.toString());
    }

    private static void get_subsets(String[] source, ArrayList<String> prefix, int offset, ArrayList<ArrayList<String>> result) {
        result.add(new ArrayList<>(prefix));
        for (int i = offset; i < source.length; i++) {
            prefix.add(source[i]);
            get_subsets(source, prefix, i + 1, result);
            prefix.remove(prefix.size() - 1);
        }
    }
}

